<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('撤回奖励')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-reward-edit" th:object="${sysReward}">
            <input name="id" id="ktid" th:field="*{id}" type="hidden">
            <input name="urlFlag" id="urlFlag" th:field="*{urlFlag}"  type="hidden">
            <input name="state" id="state" th:field="*{state}" type="hidden">
            <div class="row">

                <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">申请人：</label>
                    <div class="col-sm-8">
                        <input  disabled th:field="*{userName}" class="form-control" type="text" >
                        <input name="userId" th:field="*{userId}" class="form-control" type="hidden" required>
                        <!--                    <select name="userId" class="form-control m-b" readonly >-->
                        <!--                        <option th:each="user : ${sysUsers1}" th:text="${user.userName}" th:value="${user.userId}" th:selected="${ user.userId == sciHorizontalApply.userId}"></option>-->
                        <!--                    </select>-->
                    </div>
                </div>
                </div>

                <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">荣誉名称：</label>
                    <div class="col-sm-8">
                        <input name="rewardName" th:field="*{rewardName}" class="form-control" type="text" required disabled>
                    </div>
                </div>
                </div>

                <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">颁发单位：</label>
                    <div class="col-sm-8">
                        <input name="rewardDanwei" th:field="*{rewardDanwei}" class="form-control" type="text" required disabled>
                    </div>
                </div>
                </div>

                <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">奖励类型：</label>
                    <div class="col-sm-8">
                        <input name="rewardLeixing" th:field="*{rewardLeixing}" class="form-control" type="text" required disabled>
                    </div>
                </div>
                </div>


                <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">颁发时间：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <input name="rewardTime" th:value="${#dates.format(sysReward.rewardTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" required disabled>
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        </div>
                    </div>
                </div>
                </div>

                <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">分类：</label>
                    <div class="col-sm-8">
                        <select name="rewardFenlei" class="form-control" th:field="*{rewardFenlei}" type="text" th:with="type=${@dict.getType('sys_reward_fenlei')}" required disabled>
<!--                            <option value="省级教学成果奖">省级教学成果奖</option>-->
<!--                            <option value="省级科学技术奖">省级科学技术奖</option>-->
<!--                            <option value="省级一流精品课评比">省级一流精品课评比</option>-->
<!--                            <option value="市、厅局级自然科学类评奖">市、厅局级自然科学类评奖</option>-->
<!--                            <option value="市、厅局级社科类评奖">市、厅局级社科类评奖</option>-->
<!--                            <option value="校级教学成果奖">校级教学成果奖</option>-->
<!--                            <option value="应用型科研校级成果奖">应用型科研校级成果奖</option>-->
<!--                            <option value="校级精品课评比">校级精品课评比</option>-->
<!--                            <option value="指导学生参加国家科创大赛且获得名次">指导学生参加国家科创大赛且获得名次</option>-->
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                    </div>
                </div>
                </div>

                <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">排名：</label>
                    <div class="col-sm-8">
                        <select name="rewardPaiming" th:field="*{rewardPaiming}" class="form-control" type="text" th:with="type=${@dict.getType('sys_reward_paiming')}" required disabled>
<!--                            <option value="一">一</option>-->
<!--                            <option value="二">二</option>-->
<!--                            <option value="三">三</option>-->
<!--                            <option value="四">四</option>-->
<!--                            <option value="五">五</option>-->
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                    </div>
                </div>
                </div>

                <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label is-required" for="rewardJibie">级别：</label>
                <div class="col-sm-8">
                    <select id="rewardJibie" th:field="*{rewardJibie}" class="form-control" required disabled>
                        <option value="校级">校级</option>
                        <option value="省级">省级</option>
                    </select>
                </div>
            </div>
                </div>

                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">证书文件：</label>
                        <div class="col-sm-8">
                            <input type="hidden" name="rewardWenjian" th:field="*{rewardWenjian}" disabled>
<!--                            <div class="file-loading">-->
<!--                                <input class="form-control file-upload" id="rewardWenjian" name="file" type="file">-->
<!--                            </div>-->
                            <div style="display: inline-block;">
                                <div id="rewardWenjianFileName" style="display: inline; margin-right: 5px;"></div>
                            </div>
                            <div>
                                <button onclick="chakan()" class="btn btn-sm btn-primary color">预览</button>
                                <button onclick="downloadFile('rewardWenjian')" class="btn btn-sm btn-primary color">下载</button>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label is-required">等级：</label>
                <div class="col-sm-8">
                    <select id="rewarDengji"  th:field="*{rewardDengji}" class="form-control" type="text" th:with="type=${@dict.getType('sys_reward_dengji')}" required disabled>
<!--                        <option value="一等奖">一等奖</option>-->
<!--                        <option value="二等奖">二等奖</option>-->
<!--                        <option value="三等奖">三等奖</option>-->
<!--                        <option value="四等奖">四等奖</option>-->
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
                </div>
            </div>

            <h4 class="form-header h4">退回原因</h4>
            <div class="row">
                <div class="col-sm-12">
                    <div class="form-group">
                        <label class="col-xs-2 control-label">批注：</label>
                        <div class="col-xs-10">
                            <textarea name="remark" required maxlength="500" class="form-control" rows="3"></textarea>
                        </div>
                    </div>
                </div>
            </div>
                <h4 class="form-header h4 tdiv2"  style="display:none;">批阅记录</h4>
                <div class="row tdiv2" style="display:none;">
                    <div class="col-sm-12">

                        <div class="form-group"  >
                            <table id='bootstrap-table'></table>
                        </div>
                    </div>
                </div>

        </form>
    </div>
    <div class="row">
        <div class="col-sm-offset-5 col-sm-10">
            <button type="button" id="btn1" style="display:none;" class="btn btn-sm btn-danger" onclick="submitHandler()"><i class="fa fa-reply-all"></i>撤 回</button>&nbsp;
            <button type="button" id="btn3"  class="btn btn-sm btn-warning" style="display:none;" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <script type="text/javascript">
        var prefix = ctx + "system/reward";

        $("#form-reward-edit").validate({
            focusCleanup: true
        });


        $(function(){
            var kid = $("#ktid").val();
            var options = {
                url: prefix + "/bhyy/"+kid,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                pagination:false,

                columns: [

                    {
                        field : 'createTime',
                        title : '批阅时间',
                        width: 200

                    } ,
                    {
                        field : 'uname',
                        title : '批阅人',
                        width: 100
                    },
                    {
                        field : 'concate',
                        title : '内容',
                        width: 500
                    },
                    {
                        field : 'state',
                        title : '审核状态',
                        width: 100
                    }
                    //
                    // {
                    //     field: 'status',
                    //     title: '批阅状态',
                    //     align: 'center',
                    //     formatter: function(value, row, index) {
                    //         return $.table.selectDictLabel(datas, value);
                    //     }
                    // }
                ]
            };
            $.table.init(options);
            $('#bootstrap-table').on('load-success.bs.table', function (e, name, args) {
                    console.log('Event Name:', name.rows);

                    var a =$("#state").val();
                    console.log('Value of a:', a);
                    // if ($("#urlFlag").val() == 'chakan'){
                    //     $("#btn3").show();
                    //     // $(".tdiv2").show()
                    // }else {
                    //     if(a == 2 ||a == 1 || a == 4){
                    //
                    $(".tdiv2").show();

                    $(".tdiv1").show();
                    $("#btn1").show();
                    $("#btn2").show();
                    $("#btn3").show();
                    // }

                    // }
                }
            );
        });
    </script>
    <script th:inline="javascript">
        var prefix = ctx + "system/reward";
        $("#form-reward-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.saveTab(prefix + "/recallsave", $('#form-reward-edit').serialize());
            }
        }
        function chakan(){
            var c = $("#rewardWenjian").val();
            $.modal.openTab("查看证书文件" ,c );
        }

        $("input[name='rewardTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $(".file-upload").each(function (i) {
            var val = $("input[name='" + this.id + "']").val()
            $(this).fileinput({
                'uploadUrl': ctx + 'common/upload',
                initialPreviewAsData: true,
                initialPreview: [val],
                maxFileCount: 1,
                autoReplace: true
            }).on('fileuploaded', function (event, data, previewId, index) {
                $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('')
            })
            $(this).fileinput('_initFileActions');
        });
        // 页面加载时显示文件名
        window.onload = function() {
            // displayFileName('contract', 'contractFileName');
            displayFileName('rewardWenjian', 'rewardWenjianFileName');
        };
    </script>
</body>
</html>